Step 3 - Animate the button that the user drags

In this step you fine-tune the implementation of the drag and drop functionality by playing an animation that wiggles the button when the user drags it.

To animate the button that the user drags:

  1. In Kanzi Studio in the Prefabs > Drag Item prefab select the Image node, in the Node Components > Animation section click + Add Animation, and select Animation Player.
  2. In the Animation Player set:
    • Target Animation Timeline to Shake
    • Autoplay Enabled to enabled
      Autoplay Enabled sets whether the animation starts immediately after Kanzi attaches the node with the Animation Player to the scene graph.
    • Repeat Count Infinite to enabled
      In the Repeat Count property when you enable the Infinite property, the Animation Player plays the animation infinite amount of times.
  3. In the Properties add the Render Transformation Origin property and set the X and Y property fields to 0,5.
    This way you set the animation to move the node from the center point of the node, instead of its top-left corner.
  4. Select File > Export > Export KZB.
  5. In Visual Studio run your application.
    When you drag a button, it wiggles.


< PREVIOUS STEP

What's next?

In this tutorial you learned how to use the drag-and-drop manipulator to reorder the buttons in a navigation bar. Now you can:

See also

To learn more about animations, see Animations.

To learn how to deploy your Kanzi application to different platforms, see Deploying Kanzi applications.